Computers operate under the control of a program consisting of coded instructions. Typically, programs are first written in a high level programming language, such as BASIC, PASCAL, C, C++, or the like, which are more readily understood by humans. These high level language statements of the program are then translated or compiled into coded instructions which are executable by the computer. Typically, a software program known as a compiler is used for this purpose. The terms, "source code" and "object code," are often used to describe the form of a program prior to and after compiling, respectively. Accordingly, the term "source code" generally refers to a program in its high level programming language form. "Object code," on the other hand, generally refers to the program in the form of the coded instructions generated by the compiler which are executable on a computer.
Processes for compiling source code into executable object code are well known in the art. In a typical previous compiler, the compiler initially performs lexical analysis on the source code to separate the source code into various lexical structures of the programming language (generally known as tokens), such as keywords, identifiers, operator symbols, punctuation, and the like. Then, through syntax analysis, the compiler groups the tokens into various syntax structures of the programming language, such as expressions, declaration statements, loop statements, procedure calls, and the like. Finally, the compiler generates and optimizes code for each of these structures.
The process of compiling source code to executable object code is, for typical high level programming languages, a complex and time consuming task. Depending on the length of a program's source code and the complexity of the programming language, compiling a program may take from many seconds to many minutes. Lengthy compile times, however, are inconvenient and disruptive to programmers. When developing a program, it is often necessary to repeat the compiling process many times to remove coding and design errors, and to add further features as the program evolves from prototype to finished product. Additionally, as the program evolves, the length of the program's source code and, consequently, the compile time generally increase.
The duration of compile times can be particularly inconvenient during the process of debugging source code. When debugging a compiled program, a programmer typically makes a small change to the program's source code, compiles the program again, and tests its execution. Not uncommonly, these steps are performed repeatedly until the last error in the program is corrected. As the programmer may be left idle while the computer compiles, the time required for compiling can be an aggravating, as well as time consuming, part of the process.
With many previous compilers, the compiling process begins anew each time a program is compiled. No part of the previously compiled object code is used. Instead, the compiler repeats the compilation process from the beginning on the entire source code. As a result, the length of compile time for a program can be substantially the same regardless of whether a small change or many major modifications were made to the source code.
The Microsoft Visual Basic.RTM. version 3 language system includes a compiler which achieves shorter compile times for previously compiled programs by recompiling only a program unit which has been edited. In this language system, the source code of a program is organized into program units referred to herein as modules. Each module contains procedures, type declarations, and data element declarations. When an edit is performed to a module which can affect only the compilation of that module, the Visual Basic.RTM. version 3 compiler recompiles only the edited module. Depending on the type of edit to the module, the compiler may only repeat a portion of the compilation process for the module. Also, when an edit to a procedure within a module scan affect only the compilation of the procedure, only the edited procedure of the module is recompiled rather than the entire module. By recompiling only an edited program unit, the program may recompile in a shorter time than is required for a complete recompile of the entire source code.
A drawback to the approach in the Visual Basic.RTM. version 3 language system is that many edits to a module or its procedures can affect the compilation of other modules and their procedures. In such a case, the Visual Basic.RTM. version 3 language system recompiles all the modules of the program, whether or not the edit would actually affect a particular module.
Yet another drawback of previous compilers is that programs are generally saved to a mass storage device in either uncompiled source code form, or in an executable object code form. With a type of compiler sometimes referred to as an interpreter, programs typically are saved in source code form. (The term compiler is used herein to refer to any software program whose purpose is to translate program code whether typically categorized as a compiler or an interpreter.) Each time the saved source code is loaded for execution, the compiler must additionally repeat the compiling process anew (whether or not any edit is made to the program). Accordingly, loading programs saved as source code for execution is slow.
Other compilers can save programs to a mass storage device in object code form. Whereas source code can generally be compiled to execute on any type of computer (assuming a suitable compiler is available), object code is generally executable on only a specific type of computer. (The form of a program which is specific to a particular computer type is herein referred to as native code.) For example, object code which is native to computers using an Intel 80.times.86 type microprocessor, will not execute on computers using a Motorola 680.times.0 type microprocessor. Accordingly, programs saved as object code are generally lacking in portability (not easily transferrable) to other types of computers.
Another drawback of some previous compilers is that an entire program must be loaded, compiled and executed, even when it is desired to execute only a part of the program.
An object of the invention is to reduce the time for compiling a program after an edit. Another object of the invention is to make the time for compiling a program after an edit generally related to the extent of the edit. A further object is to reduce the compile time of programs which are loaded for execution. A further object is to recompile only those portions of a program actually affected by an edit, and only to the extent each portion is affected by the edit.